// eslint-disable-next-line consistent-return
function initArea(mapSelf: { addOverLay: (arg0: any) => void }) {
  // @ts-ignore
  const {T} = window

  function openInfo(content, e) {
    const point = e.lnglat
    const marker = new T.Marker(point) // 创建标注
    const markerInfoWin = new T.InfoWindow(content, { offset: new T.Point(0, -30) }) // 创建信息窗口对象
    mapSelf.openInfoWindow(markerInfoWin, point) // 开启信息窗口
  }

  function addClickHandler(content, marker) {
    marker.addEventListener('click', function (e) {
      openInfo(content, e)
    })
  }



  // init start

  // todo mock data
  const data_info  = [
    [116.417854, 39.921988, '地址：北京市东城区王府井大街88号乐天银泰百货八层'],
    [116.406605, 39.921585, '地址：北京市东城区东华门大街'],
    [116.412222, 39.912345, '地址：北京市东城区正义路甲5号']
  ]

  for (let i = 0; i < data_info.length; i++) {
    const marker = new T.Marker(new T.LngLat(data_info[i][0], data_info[i][1])) // 创建标注
    const content = data_info[i][2]
    mapSelf.addOverLay(marker) // 将标注添加到地图中
    addClickHandler(content, marker)
  }
}


export default initArea
